kosfandomcom-20200214-history
Example - Descend Lander/Skycrane
New version for KOS 0.92 Here. The code has been updated to KOS 0.92 and will no longer run on versions older than that. Complex This is a complex example attempting to do a lot of work. Do not start with it as your first example. It is meant to demonstrate how complex the system can get. WARNING: CODE IS TOO BIG - MUST STRIP COMMENTS The code shown here will not fit in a 10k SCS module unless comments are stripped. This is because it was written with very large amounts of comments in it precisely because it is an example to look at. To run it you need to either edit out the comments or run it on a craft that has range to see the archive back home and can run it from there. To strip comments you can simply do a regular-expression search and replace (assuming your text editor has that feature) to replace [ \t]*\/\/.*$ with null-string. (And while you're at it, you can strip the leading indent spaces with the regular expression search for ^[ \t]* and replace with null-string.) How To Use # Make sure all the example code at the bottom of this page exists where you can call it. # There are two ways to handle the large size of the code. Do either one of these two things: ## Make sure the craft can see radio range to the archive to run the code from there. ## Make sure you have stripped out the comments from the "descend" code to bring it down within the size limits of the SCS module. # Put your vessel into a configuration where it will dip low near the SOI body, or even impact it. As long as your altitude will dip below the setting descendTop from the bodystats program it should work. # This example only supports Kerbin, Mun, and Minmus. To use elsewhere you'll have to edit the 'bodystats' program appropriately first. # Make sure you've gotten your vessel to the point in its staging list where it has the landing engines active but not throttled up yet. The script cannot "see" the configuration of your vessel's parts and doesn't know which stage is the one you want it to be on, so it doesn't try to guess. # run bodystats(body). # run descend( type, slopeMax ). (where type is one of: "skycrane", "lander", or "hover", and slopeMax is the maximum slope you'll accept for a landing site (where slope is measured as height/horizontaldist, such that a slope of 1.0 means the land is at a 45 degree angle for example). # Design of the vessel: ## Your Vessel must be able to rotate toward the retrograde vector without the use of RCS thrusters. (Make sure it has adequate torque wheels). The script does not use RCS and assumes you can rotate without it. ## For skycrane use only: Make sure the vessel is designed so that the very next staging list activation after the current one will be the one that drops the payload. The script performs a single "stage" activation at the point it tries to drop the payload. Version problems This was first written for KOS 0.65. Some new changes in 0.7 and 0.8 make it not work so well: * 0.71 has a bug with the missionTime value such that trying to perform math operations on it produces the wrong results. In this case it causes the script to believe zero time has passed between loop iterations, which in turn makes it think the slope of terrain under the craft is infinity, making it never satisfied with a place to land. When using this in OS 0.71 you may need to hardcode the slope to just be zero all the time and ignore that part of the code's features. * 0.8x is too broken to test with at this moment. Assume the example won't work at all with 0.8x until further notice. The actual files Alternate file location Alternately instead of looking here, the files are hosted on a google drive of the author, where they are public and more likely to get updated. However Wikia is quite spam-tastic and therefore I (the author) don't relish the idea of posting a link to the drive in the text here. Make a comment at the bottom of the page if you want to get to the google drive and I will send you a private notification to your Wikia account with the URL. Files stored here "database" files These files are here to obtain data that KOS currently (0.92) doesn't give about the KSP game - the stats on bodies, the stats on parachutes, etc). They both work on the principle that the archive back home contains the full data and the smaller program stored locally on the volume just gets the data from the home archive file: File 1.1: call it " " File 1.2: call it " " File 1.3: call it " " File 1.4: call it " " Utility file for matrix mathy stuff File 2: call it " " The actual bulk of the code File 3: Call it " " Category:Examples